﻿<%@ Page Title="Quản lý câu hỏi" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="frmAdTaoCH.aspx.cs" Inherits="Admin_frmAdTaoCH" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


                               <div class="wrap">
        <h2>
            Quản lý câu hỏi |
            <asp:HyperLink ID="HyperLink2" runat="server" CssClass="node"
            NavigateUrl="~/Admin/ThongTinCauHoi.aspx" BackColor="#F1F1F1" >Thêm câu hỏi</asp:HyperLink>
        </h2>
    </div>
       <div style="float:left;width:10%; height: 36px;"><div style="margin-top:5px;"><span style="text-align:justify;">Chọn Môn Học </span></div>
       </div> <div style="float:right; width:90%; height: 34px;">
       
            <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                ContextTypeName="DataClassesDataContext" Select="new (TenMonHoc, MsMonHoc)" 
                TableName="tbl_MONHOCs">
            </asp:LinqDataSource>
                                   <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                       <ContentTemplate>
                                           <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
                DataSourceID="LinqDataSource1" DataTextField="TenMonHoc" 
                DataValueField="MsMonHoc" Height="25px" Width="150px">
                                           </asp:DropDownList>
                                       </ContentTemplate>
                                   </asp:UpdatePanel>
                               </div>

    
<%--    <table class="style1">
    <tr>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style2">
            <asp:Label ID="Label2" runat="server" Text="Noi Dung"></asp:Label>
        </td>
        <td class="style2">
            <asp:UpdatePanel ID="UpdatePanel8" runat="server">
                <ContentTemplate>
                    <asp:TextBox ID="txtNoidungCH" runat="server" Enabled="False" Height="65px" 
                TextMode="MultiLine" Width="495px"></asp:TextBox>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
        <td class="style2">
            <asp:Button ID="btnXoaCH" runat="server" onclick="btnXoaCH_Click" Text="Xoa CH" CssClass="button"
                    Width="85px" Height="27px" Visible="False" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label3" runat="server" Text="Muc Do"></asp:Label>
        </td>
        <td>
            <asp:UpdatePanel ID="UpdatePanel9" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="drplMucdo" runat="server" Enabled="False" 
    Width="126px">
                        <asp:ListItem>Kho</asp:ListItem>
                        <asp:ListItem>De</asp:ListItem>
                        <asp:ListItem>TB</asp:ListItem>
                    </asp:DropDownList>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
        <td>
            <asp:Button ID="btnSua" runat="server" onclick="btnSua_Click" Text="Sua CH" CssClass="button"
                    Width="85px" Height="27px" Visible="False" />
        </td>
    </tr>
    <tr>
        <td class="style3">
            <asp:RadioButton ID="rdbA" runat="server" GroupName="cauhoi" Text="Câu A" />
        </td>
        <td class="style3">
            <asp:UpdatePanel ID="UpdatePanel6" runat="server">
                <ContentTemplate>
                    <asp:TextBox ID="txtA" runat="server" Enabled="False" 
                    ontextchanged="txtA_TextChanged" Height="34px" TextMode="MultiLine" 
                        Width="492px"></asp:TextBox>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
        <td class="style3">
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            <asp:RadioButton ID="rdbB" runat="server" GroupName="cauhoi" Text="Câu B" />
        </td>
        <td>
                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                    <ContentTemplate>
                        <asp:TextBox ID="txtB" runat="server" Enabled="False" 
                    ontextchanged="txtB_TextChanged" TextMode="MultiLine" Width="492px"></asp:TextBox>

                    </ContentTemplate>
                </asp:UpdatePanel>

        <td>
                &nbsp;</td>
    </tr>
    <tr>
        <td>
            <asp:RadioButton ID="rdbC" runat="server" GroupName="cauhoi" Text="Câu C" />
        </td>
        <td>
                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                    <ContentTemplate>
                        <asp:TextBox ID="txtC" runat="server" Enabled="False" 
                    ontextchanged="txtC_TextChanged" TextMode="MultiLine" Width="491px"></asp:TextBox>
                    </ContentTemplate>
                </asp:UpdatePanel>
        </td>
        <td>
                &nbsp;</td>
    </tr>
    <tr>
        <td>
            <asp:RadioButton ID="rdbD" runat="server" GroupName="cauhoi" Text="Câu D" 
                />
        </td>
        <td>
                <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                    <ContentTemplate>
                        <asp:TextBox ID="txtD" runat="server" Enabled="False" 
                    ontextchanged="txtD_TextChanged" TextMode="MultiLine" Width="491px"></asp:TextBox>
                    </ContentTemplate>
                </asp:UpdatePanel>
        </td>
        <td>
                &nbsp;</td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label4" runat="server" Text="Môn Học"></asp:Label>
        </td>
        <td>
            <asp:UpdatePanel ID="UpdatePanel7" runat="server">
                <ContentTemplate>
                    <asp:DropDownList ID="drlMonHoc" runat="server" DataSourceID="LinqDataSource1" 
                        DataTextField="TenMonHoc" DataValueField="MsMonHoc" Height="30px" 
                        Width="122px" AutoPostBack="True">
                    </asp:DropDownList>
                    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                        ContextTypeName="DataClassesDataContext" Select="new (MsMonHoc, TenMonHoc)" 
                        TableName="tbl_MONHOCs">
                    </asp:LinqDataSource>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
        <td>
            <asp:Button ID="btnHuy" runat="server" CssClass="button" Height="27px" 
                onclick="btnHuy_Click" Text="Huy Thao Tac" Visible="False" Width="85px" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label5" runat="server" Text="Chương Học"></asp:Label>
        </td>
        <td>
                <asp:UpdatePanel ID="UpdatePanel11" runat="server">
                    <ContentTemplate>
                        <asp:DropDownList ID="drlChuongHoc" runat="server" Height="30px" 
                             Width="122px" AutoPostBack="True" DataSourceID="LinqDataSource2" 
                            DataTextField="TenChuong" DataValueField="MaChuong">
                        </asp:DropDownList>
                        <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
                            ContextTypeName="DataClassesDataContext" Select="new (MaChuong, TenChuong)" 
                            TableName="tbl_CHUONGHOCs" Where="MsMonHoc == @MsMonHoc">
                            <WhereParameters>
                                <asp:ControlParameter ControlID="drlMonHoc" Name="MsMonHoc" 
                                    PropertyName="SelectedValue" Type="String" />
                            </WhereParameters>
                        </asp:LinqDataSource>
                    </ContentTemplate>
                </asp:UpdatePanel>
        </td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td>
                    <asp:Button ID="btnThemCH" runat="server" onclick="btnThemCH_Click" CssClass="button"
                    Text="Them CH" Width="85px" Height="27px" />
        </td>
        <td>
                &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
</table>
--%>

<br/>
    
    
    <div align="center" style="width:98%; border: solid 1px #CCCCCC;padding-top:7px; height:auto;  overflow:auto;">
           <asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <ContentTemplate>
                   <div align="left">
                       <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" CssClass="GridViewStyle" 
                DataKeyNames="Idnganhangch" DataSourceID="SqlDataSource1" GridLines="None" 
                onrowcommand="GridView1_RowCommand" Width="100%" PageSize="20">
                           <Columns>
                               <asp:TemplateField HeaderText="">
                                   <ItemTemplate>
                                       <input name="MyRadioButton" style="width:35px;" type="radio" 
                                value='<%# Eval("MaCH") %>' />
                                   </ItemTemplate>
                               </asp:TemplateField>
                               <asp:BoundField DataField="MaCH" HeaderText="Mã Câu Hỏi" 
                        SortExpression="MaCH" />
                               <asp:BoundField DataField="TenMonHoc" HeaderText="TenMonHoc" 
                        SortExpression="TenMonHoc" />
                               <asp:BoundField DataField="NoiDungCH" HeaderText="Nội Dung" 
                        SortExpression="NoiDungCH">
                                   <ItemStyle Width="350px" />
                               </asp:BoundField>
                               <asp:BoundField DataField="DA1" HeaderText="Phương Án 1" SortExpression="DA1">
                                   <ItemStyle Width="100px" />
                               </asp:BoundField>
                               <asp:BoundField DataField="DA2" HeaderText="Phương Án 2" SortExpression="DA2">
                                   <ItemStyle Width="100px" />
                               </asp:BoundField>
                               <asp:BoundField DataField="DA3" HeaderText="Phương Án 3" SortExpression="DA3">
                                   <ItemStyle Width="100px" />
                               </asp:BoundField>
                               <asp:BoundField DataField="DA4" HeaderText="Phương Án 4" SortExpression="DA4">
                                   <ItemStyle Width="100px" />
                               </asp:BoundField>
                               <asp:BoundField DataField="DADUNG" HeaderText="Đáp Án" SortExpression="DADUNG">
                                   <ItemStyle Width="100px" />
                               </asp:BoundField>
                               <asp:BoundField DataField="Mucdo" HeaderText="Mức Độ" SortExpression="Mucdo">
                                   <ItemStyle Width="50px" />
                               </asp:BoundField>
                               <asp:HyperLinkField DataNavigateUrlFields="MaCH" 
                        DataNavigateUrlFormatString="~/Admin/ThongTinCauHoi.aspx?mach={0}" 
                        Text="Sửa" />
                               <asp:TemplateField ShowHeader="False">
                                   <ItemTemplate>
                                       <asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="true" 
                                CommandArgument='<%#Eval("MaCH") %>' CommandName="MyDelete" 
                                ImageUrl="../Images/cross.png" style="padding-left:10px; padding-right:10px;" 
                                Text="Delete" />
                                       <ajaxToolkit:ModalPopupExtender ID="lnkDelete_ModalPopupExtender" 
                                runat="server" BackgroundCssClass="modalBackground" 
                                CancelControlID="ButtonDeleteCancel" OkControlID="ButtonDeleleOkay" 
                                PopupControlID="DivDeleteConfirmation" TargetControlID="ImageButton2">
                                       </ajaxToolkit:ModalPopupExtender>
                                       <ajaxToolkit:ConfirmButtonExtender ID="lnkDelete_ConfirmButtonExtender" 
                                runat="server" DisplayModalPopupID="lnkDelete_ModalPopupExtender" 
                                Enabled="True" TargetControlID="ImageButton2">
                                       </ajaxToolkit:ConfirmButtonExtender>
                                   </ItemTemplate>
                               </asp:TemplateField>
                           </Columns>
                           <RowStyle CssClass="RowStyle" />
                           <EmptyDataRowStyle CssClass="EmptyRowStyle" />
                           <PagerStyle CssClass="PagerStyle" />
                           <SelectedRowStyle CssClass="SelectedRowStyle" />
                           <HeaderStyle CssClass="HeaderStyle" />
                           <EditRowStyle CssClass="EditRowStyle" />
                           <AlternatingRowStyle CssClass="AltRowStyle" />
                       </asp:GridView>
                   </div>
               </ContentTemplate>
           </asp:UpdatePanel>
        
        <br />
        
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:TracNghiemTrucTuyenConnectionString %>" 
                
            
            
            SelectCommand="SELECT tbl_MONHOC.TenMonHoc, tbl_NGANHANGCAUHOI.Idnganhangch, tbl_NGANHANGCAUHOI.MaCH, tbl_NGANHANGCAUHOI.NoiDungCH, tbl_NGANHANGCAUHOI.DA1, tbl_NGANHANGCAUHOI.DA2, tbl_NGANHANGCAUHOI.DA3, tbl_NGANHANGCAUHOI.DA4, tbl_NGANHANGCAUHOI.DADUNG, tbl_NGANHANGCAUHOI.Mucdo FROM tbl_NGANHANGCAUHOI INNER JOIN tbl_CHUONGHOC ON tbl_NGANHANGCAUHOI.MaChuong = tbl_CHUONGHOC.MaChuong INNER JOIN tbl_MONHOC ON tbl_CHUONGHOC.MsMonHoc = tbl_MONHOC.MsMonHoc WHERE tbl_NGANHANGCAUHOI.Deleted &lt;&gt; 1 and tbl_CHUONGHOC.MsMonHoc=@MsMonHoc" 
            ProviderName="<%$ ConnectionStrings:TracNghiemTrucTuyenConnectionString.ProviderName %>">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="MsMonHoc" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
    
    <%-- Bảng thông báo xóa dữ liệu--%>
        <asp:Panel runat="server" ID="DivDeleteConfirmation" Style="display: none;" class="modalBox">
        <div>
            <div class="popup_Titlebar" id="PopupHeader">
                <div class="TitlebarLeft">
                    Xóa dữ liệu</div>
                <div class="TitlebarRight" onclick="$get('ButtonDeleteCancel').click();">
                </div>
            </div>
            <div class="popup_Body">
                <p>Bạn có chắc chắn muốn xóa ? </p>
            </div>
            <div class="popup_Buttons">
                <input id="ButtonDeleleOkay" value="Okay" type="button" />
                <input id="ButtonDeleteCancel" value="Cancel" type="button" />
            </div>
        </div>
        </asp:Panel>
                               

    
        
        
<%--    <script type="text/javascript">


        function ktRadioButton() {
            
            if (($("#<%=btnThemCH.ClientID %>").val() == "Luu CH"
                && !$("#<%=rdbA.ClientID %>").is(":checked")
                && !$("#<%=rdbB.ClientID %>").is(":checked")
                && !$("#<%=rdbC.ClientID %>").is(":checked")
                && !$("#<%=rdbD.ClientID %>").is(":checked"))
                )
            {
                alert("Bạn chưa chọn đáp án nào đúng!");
                return false;
            }
            if ($("#<%=btnThemCH.ClientID %>").val() == "Luu CH" 
                &&(($.trim($("#<%=txtA.ClientID %>").val()) == 0)
                || ($.trim($("#<%=txtB.ClientID %>").val()) == 0)
                || ($.trim($("#<%=txtC.ClientID %>").val()) == 0)
                || ($.trim($("#<%=txtD.ClientID %>").val()) == 0)))
            {
                alert("Thông báo! Có đáp án còn để trống!");
                return false;
                
            }
            if ($("#<%=btnThemCH.ClientID %>").val() == "Luu CH" 
                &&(($.trim($("#<%=drlChuongHoc.ClientID %>").val()) == 0)))
            {
                alert("Thông báo! Môn học này chưa có chương nào!");
                return false;
            }
        }
    </script>
--%>
</asp:Content>

